﻿using System;
using System.Windows.Forms;
using Topshelf;
using System.IO;

namespace SocketClient
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(string [] args)
        {
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config"));
            if (args.Length != 0 && args[0].Equals("login"))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new LoginForm());
            }
            else
            {

                HostFactory.Run(x =>
                {
                    x.Service<InitSocket>((s) =>
                    {
                        s.SetServiceName("ser");
                        s.ConstructUsing(name => new InitSocket());
                        s.WhenStarted((t) => t.Start());
                        s.WhenStopped((t) => t.Stop());
                    });

                    x.RunAsLocalSystem();

                    //服务的描述
                    x.SetDescription("Socket_Print_description");
                    //服务的显示名称
                    x.SetDisplayName("Socket_Print_display");
                    //服务名称
                    x.SetServiceName("Socket_Print_service");

                });
            }

        }
    }
}
